package cn.oa.dao;

import cn.oa.entity.Department;
import cn.oa.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.junit.Test;

import java.sql.SQLException;
import java.util.List;

public class DepartmentText {
    SqlSessionFactory sqlSessionFactory = MybatisUtil.sessionFactory;
    SqlSession sqlSession = sqlSessionFactory.openSession();
    private Logger logger = Logger.getLogger(DepartmentText.class);
    @Test
    public void getAllDepartments() throws SQLException {
        DepartmentDao departmentDao = sqlSession.getMapper(DepartmentDao.class);
        List<Department> userList = departmentDao.getAllDepartments();
        for (Department department : userList) {
            System.out.println(department);
        }
        sqlSession.close();
    }

}

